package de.dopichaj.labrador.search.hit;

import java.util.Comparator;

public final class PosComparator  implements Comparator<Hit> {
    
    public static final Comparator<Hit> INSTANCE = new PosComparator();
    
    public int compare(Hit hit1, Hit hit2) {
        int pos1 = hit1.getPosition();
        int pos2 = hit2.getPosition();
        if (pos1 < pos2) {
            return -1;
        } else if (pos1 > pos2) {
            return 1;
        } else {
            return hit1.getDepth() > hit2.getDepth() ? -1 : 1;
        }
    }
}